#include "primary_include_file.h"
#include <ctype.h>
#include "parser/scansup.h"
#include "mb/op_wchar.h"

/* downcase_truncate_identifier()---
 *   do appropriate downcasting and truncation of an unquoted
 * identifier. Optionally warn of truncation.
 *  return a malloc'd string containing the adjusted indentifier.
 */
/* _line_129 */
char *
downcase_truncate_identifier(const char *ident, int len, bool warn)
{
  char *result;
  int i;

  result = (char *)malloc(len + 1);

  for (i = 0; i < len; ++i) {
    unsigned char ch = (unsigned char)ident[i];
    
    if (ch >= 'A' && ch <= 'Z'){
      ch += 'a' - 'A';
    } else if (IS_HIGHBIT_SET(ch) && isupper(ch)) {
      ch = tolower(ch);
    }
  }
  result[i] = '\0';

  if (i >= 64)
    ;

  return result;
}
